Repository navigation
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b4d547a30c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| // No dispatch to pace, so the domain keeps its slot. | ||
| state.crawlDelayUntil = crawlDelayUntilBefore; | ||
| state.lastDispatchedAt = lastDispatchedAtBefore; |
There was a problem hiding this comment.
Preserve newer dispatch timestamps when an empty fetch completes
When minCrawlDelaySecs is 0 and same-domain fetches overlap before a crawl delay is known, an older fetch can return null after a newer fetch successfully dequeues a request. This unconditional rollback restores the older snapshot, potentially resetting lastDispatchedAt to null and erasing the successful dispatch. A subsequent robots.txt signal then skips or shortens the cooldown extension in #recordDeclaredInterval, allowing another request before the declared interval has elapsed. Rollback must preserve dispatch timestamps established by newer fetches.
Useful? React with 👍 / 👎.
|
Addressed the review finding in follow-up commit
|
### Description When one domain gets crawl-delays from several robots.txt files, `ThrottlingRequestManager` now keeps the longest one instead of the first. Several files cover one domain for a site and its subdomains under `throttle_by='registrable_domain'`, and for HTTP and HTTPS of one host. A robots.txt re-fetch still can't speed a domain up, it can only slow it down. The same change for Crawlee JS is tracked in apify/crawlee#4491, with a fix proposed in apify/crawlee#4493. ### Issues - Follow-up: #2507 *✍️ Drafted by Claude Code*
### Description When one domain gets crawl-delays from several robots.txt files, `ThrottlingRequestManager` now keeps the longest one instead of the first. Several files cover one domain for a site and its subdomains under `throttle_by='registrable_domain'`, and for HTTP and HTTPS of one host. A robots.txt re-fetch still can't speed a domain up, it can only slow it down. The same change for Crawlee JS is tracked in apify/crawlee#4491, with a fix proposed in apify/crawlee#4493. ### Issues - Follow-up: #2507 *✍️ Drafted by Claude Code*
…ch rollback Avoid writing lastDispatchedAt before a sub-queue fetch actually returns a request, and guard crawlDelayUntil rollback with a per-domain monotonic reservation token so an older empty or rejected fetch cannot overwrite a newer concurrent dispatch or purge.
8f0ea82 to
f0c4e81
Compare
Fixes #4491
Summary
lastDispatchedAtperDomainStateinpackages/basic-crawler/src/internals/throttling-request-manager.ts(restoring it when no request is dequeued and resetting it when the queue is purged).ThrottlingRequestManager.#recordDeclaredIntervalto retain the longestCrawl-delayrecorded for a domain, rather than keeping only the first signal.Crawl-delayarrives after a request has already been dispatched for a domain, extendcrawlDelayUntilfromlastDispatchedAt + effectiveDelayMs(while preservingminCrawlDelaySecswhen it is longer).Tests
test/basic-crawler/throttling-request-manager.test.tscovering:Crawl-delayreplacing an earlier shorter one across origins sharing a domain clock (subdomains underregistrableDomain, and different schemes or ports underhostname),minCrawlDelaySecsfloor behavior, andpurge()cleanly resetting dispatch timestamps.vitest run test/basic-crawler/throttling-request-manager.test.ts test/core/crawlers/basic-crawler.test.ts test/core/request-manager-tandem.test.ts: 3 files passed (294 tests passed).tsc -p tsconfig.build.jsonandscripts/copy.ts),tsc --noEmit --project test/tsconfig.json,oxlint --type-aware, andoxfmt --checkon the changed files all passed with 0 errors and 0 warnings.Note: This pull request was prepared with AI-assisted coding and verified locally against the test suite, TypeScript compiler, linter, and formatter.